﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace TextEditor.TextDocument.Control
{
    public partial class ucFindOrReplace : UserControl
    {
        public delegate void Find(object o,string s);
        public delegate void Replace(string s1,string s2);
        public event Find OnFind;
        public event Replace OnReplace;
        public ucFindOrReplace()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (OnFind != null)
            {
                OnFind(sender, this.textBox1.Text.Trim());
            }
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            this.textBox2.Enabled = checkBox1.Checked;
            this.button3.Enabled = checkBox1.Checked;
        }

        private void button3_Click(object sender, EventArgs e)
        {

            if (OnReplace != null) 
            {
                OnReplace(this.textBox1.Text.Trim(), this.textBox2.Text.Trim());
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            if (this.Parent != null)
                this.Parent.Height -= 29;
        }
    }
}
